package com.apes.scm.account.account.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.account.account.model.DetailOfLend;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by HuJianlin on 2018-01-30.
 */
public interface DetailOfLendRepository extends CustomRepository<DetailOfLend, Long> {
    /**
     * 更新借还在途明细账
     * @param productId
     * @param locationId
     * @param personId
     * @param lendQty
     * @return
     */
    @Modifying
    @Query("update DetailOfLend" +
            "   set lend_qty = lend_qty + :lendQty" +
            " where product_id = :productId" +
            "   and location_id = :locationId" +
            "   and person_id = :personId")
    public int update(@Param("productId")String productId,
                      @Param("locationId")String locationId,
                      @Param("personId")String personId,
                      @Param("lendQty")double lendQty);
}
